<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>max</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="massign.html" title="massign" />
    <link rel="next" href="maxabs.html" title="maxabs" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">max</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="massign.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="maxabs.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="max"></a>
      <div class="titlepage"></div>
      <a id="IndexMax" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">max</span>
        </h2>
        <p>max — 
      Produces a signal that is the maximum of any number of input signals.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp122841680"></a>
        <h2>Description</h2>
        <p>
      The <span class="emphasis"><em>max</em></span> opcode takes any number of a-rate,
      k-rate or i-rate signals as input (all of the same rate), and outputs a signal at the same rate that is the maximum of all of the inputs.  For a-rate signals, the inputs are compared one sample at a time (i.e. <span class="emphasis"><em>max</em></span> does not scan an entire ksmps period of a signal for its local maximum as the <span class="emphasis"><em>max_k</em></span> opcode does).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122844320"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">amax <span class="command"><strong>max</strong></span> ain1, ain2 [, ain3] [, ain4] [...]</pre>
        <pre class="synopsis">kmax <span class="command"><strong>max</strong></span> kin1, kin2 [, kin3] [, kin4] [...]</pre>
        <pre class="synopsis">imax <span class="command"><strong>max</strong></span> iin1, iin2 [, iin3] [, iin4] [...]</pre>
      </div>
      <div class="refsect1">
        <a id="idp122849296"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ain1, ain2, ...</em></span> --  a-rate signals to be compared.
    </p>
        <p>
      <span class="emphasis"><em>kin1, kin2, ...</em></span> --  k-rate signals to be compared.
    </p>
        <p>
      <span class="emphasis"><em>iin1, iin2, ...</em></span> --  i-rate signals to be compared.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122852688"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the max opcode. It uses the file <a class="ulink" href="examples/max.csd" target="_top"><em class="citetitle">max.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp122854464"></a>
          <p class="title">
            <strong>Example 474. Example of the max opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac   <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o max.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1

k1   <span class="opc">oscili</span> 1, 10.0, 1			<span class="comment">;combine 3 sinusses</span>
k2   <span class="opc">oscili</span> 1, 1.0, 1			<span class="comment">;at different rates</span>
k3   <span class="opc">oscili</span> 1, 3.0, 1
kmax <span class="opc">max</span>   k1, k2, k3
kmax <span class="op">=</span> kmax<span class="op">*</span>250				<span class="comment">;scale kmax</span>
<span class="opc">printk2</span> kmax				<span class="comment">;check the values</span>

aout <span class="opc">vco2</span> .5, 220, 6			<span class="comment">;sawtooth</span>
asig <span class="opc">moogvcf2</span> aout, 600<span class="op">+</span>kmax, .5 	<span class="comment">;change filter around 600 Hz		</span>
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 32768 10 1

<span class="stamnt">i</span>1 0 5
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122858752"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="min.html" title="min"><em class="citetitle">min</em></a>, 
      <a class="link" href="maxabs.html" title="maxabs"><em class="citetitle">maxabs</em></a>, 
      <a class="link" href="minabs.html" title="minabs"><em class="citetitle">minabs</em></a>, 
      <a class="link" href="maxaccum.html" title="maxaccum"><em class="citetitle">maxaccum</em></a>, 
      <a class="link" href="minaccum.html" title="minaccum"><em class="citetitle">minaccum</em></a>, 
      <a class="link" href="maxabsaccum.html" title="maxabsaccum"><em class="citetitle">maxabsaccum</em></a>, 
      <a class="link" href="minabsaccum.html" title="minabsaccum"><em class="citetitle">minabsaccum</em></a>, 
      <a class="link" href="max_k.html" title="max_k"><em class="citetitle">max_k</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp122867456"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Anthony Kozar</td>
          </tr>
          <tr>
            <td>March 2006</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 5.01; i-rate version new in 6.04</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="massign.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="maxabs.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">massign </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> maxabs</td>
        </tr>
      </table>
    </div>
  </body>
</html>
